<?php

/** Zend_Controller_Action */
require_once ROOT_PATH . '/library/Soooner/Controller/WebAction.php';

class ShowController extends Soooner_Web_Controller_Action
{
	private $_modelScreen;
	private $_modelScreenlevelurl;
	private $_modelUrl;
	public function init()
    {
    	$this->initDzTemplate(); 
    	$this->_modelScreen = new Model_Tables_Screen();
    	$this->_modelScreenlevelurl = new Model_Tables_Screenlevelurl(); 
    	$this->_modelUrl = new Model_Tables_Url(); 	
    }
    /**
     * 监控屏框架页面，调用时回传入screenid参数,区分显示不同内容
     */
    public function indexAction(){
    	$play = 50000000;//刷新时间
    	$screenid = $this->_getParam('screenid');
    	$level = $this->_configs["level"];
    	$urllist0 = $this->_modelScreenlevelurl->getList(1,1000,$screenid,$level);
    	$urlmap = $this->_modelUrl->getUrlMap();
    	$infos = array();
    	foreach($urllist0 as $url){
    		$url["v"] = $urlmap[$url["urlid"]];
    		$newplay = $url["refresh"]*1000;
    		if($newplay <$play)
    			$play = $newplay ;
    		$infos[]=$url;
    	}
    	if(count($infos)==1){
    		$infos[] = $infos[0];
    	}
    	//echo "<pre>";
    	//print_r($urllist);exit;
        include $this->_dzTemplate->getFile( 'web/show.html' );
    }
    /**
     * 
     * 是否需要刷新框架页面
     */
    public function needflushAction(){
    	$screenid = $this->_getParam('screenid');
    	$info = $this->_modelScreen->getInfo($screenid);
    	$needflush = $info["needflush"];
    	if($needflush>0){
    		$newneedflush = $needflush -1;
    		$this->_modelScreen->modifyAjax($screenid, "needflush", $newneedflush);
    	}
    	else 
    		$newneedflush = 0;
    	echo $needflush;
    }
	/**
	 * 
	 * 测试信息
	 */
    public function monitorAction(){
    	$name = $this->_getParam('name');
    	echo "<div style='font-size:200pt'>$name</div>";
    	exit();
    }
}